import AstarNode from "./AstarNode";

/*
* name;
*/
export default class BHeapNode {
    public astarNode: AstarNode;
    public parentNode: BHeapNode;
    public leftChild: BHeapNode;
    public rightChild: BHeapNode;
    private static pool: BHeapNode[];
    constructor() {

    }

    public static create() {
        if(BHeapNode.pool && BHeapNode.pool.length>0){
            return BHeapNode.pool.pop();
        }
        return new BHeapNode();
    }

    public recover() {
        this.astarNode = null;
        this.parentNode = null;
        this.leftChild = null;
        this.rightChild = null;
        if(!BHeapNode.pool){
            BHeapNode.pool = []
        }
        if(!BHeapNode.pool.includes(this)){
            BHeapNode.pool.push(this);
        }
    }
}